# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=evince
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.28.2
pkgrel=2
arch=('any')
pkgdesc="Document (PostScript, PDF) viewer (mingw-w64)"
license=("GPL 2")
url="https://www.gnome.org"
options=('strip' 'staticlibs')
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-djvulibre"
         "${MINGW_PACKAGE_PREFIX}-gsettings-desktop-schemas"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libgxps"
         "${MINGW_PACKAGE_PREFIX}-libspectre"
         "${MINGW_PACKAGE_PREFIX}-libtiff"
         "${MINGW_PACKAGE_PREFIX}-poppler"
         "${MINGW_PACKAGE_PREFIX}-gst-plugins-base"
         "${MINGW_PACKAGE_PREFIX}-nss")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "make"
             "libtool"
             "automake-wrapper"
             "autoconf"
             "gtk-doc"
             "intltool"
             "itstool"
             "gettext-devel"
             "yelp-tools")
install=evince-${CARCH}.install
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        0002-missing-include.patch)
sha256sums=('0955d22d85c9f6d322b6cbb464f1cc4c352db619017ec95dad4cc5c3440f73e1'
            'd2850c4bdfa87fa56bae2674d2c798f9181bfb3f19319fbc9966672caae48237')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0002-missing-include.patch
  AUTOPOINT='intltoolize --automake --copy' autoreconf -f -i
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}

  PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/share/pkgconfig" \
  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection \
    --disable-dbus \
    --disable-browser-plugin \
    --disable-nautilus

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
